import request from '@/utils/request';

/**
 * 分页查询车队管理
 */
export async function pageCarTeams(params) {
  const res = await request.get('/order/carTeam/page', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询车队管理列表
 */
export async function listCarTeams(params) {
  const res = await request.get('/order/carTeam', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询车队管理
 */
export async function getCarTeam(id) {
  const res = await request.get('/order/carTeam/' + id);
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加车队管理
 */
export async function addCarTeam(data) {
  const res = await request.post('/order/carTeam', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改车队管理
 */
export async function updateCarTeam(data) {
  const res = await request.put('/order/carTeam', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除车队管理
 */
export async function removeCarTeam(id) {
  const res = await request.delete('/order/carTeam/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 审核车队管理
 */
export async function examCarTeam(data) {
  const res = await request.post('/order/carTeam/examCarTeam', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

